package cz.fit.vutbr.pis2012.augeaswh.control.whman.slots;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import cz.fit.vutbr.pis2012.augeaswh.managers.SlotsManager;
import cz.fit.vutbr.pis2012.augeaswh.persistence.Slot;

@ManagedBean
@ViewScoped
public class SlotsConfirmDeleteDialogBean {
	@EJB
	private SlotsManager sm;	
	private Slot slot;
	
	public String getTitle() {
		return "Deleting slot";
	}
	
	public String getQuestion() {
		if(this.slot==null)
			return "";
		return "Are you sure you want to delete slot "+slot.getName()+"?"; 
	}
	
	public void submit() {
		if(this.slot!=null) {
			sm.delete(this.slot);
			this.slot=null;
		}
	}

	public Slot getSlot() {
		return slot;
	}

	public void setSlot(Slot slot) {
		this.slot = slot;
	}	
}
